<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录--Wifi开关控制系统</title>
    <link href="__CSS__/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="__ADMIN__/css/login.css" rel="stylesheet" type="text/css"/>
    <script src="__JS__/jquery-3.2.1.min.js" type="text/javascript"></script>
    <script src="__JS__/jquery.cookie.js" type="text/javascript"></script>
    <script src="__JS__/jquery.base64.js" type="text/javascript"></script>
    <!--<script type="text/javascript" src="js/bootstrap.js" ></script>-->
</head>
<body>
<form id="form" action="{:U('User/loginCheck')}" method="post">
<!--<form>-->
    <div class="mycenter">
        <div class="mysign">
            <div class="col-lg-12 col-md-12 text-center text-info">
                <h3>Wifi 开关控制系统</h3>
            </div>
            <div class="col-lg-10 col-md-10">
                <input type="text" class="form-control" name="username" id="username" placeholder="用户名" required autofocus/>
            </div>
            <div class="col-lg-10 col-md-10"></div>
            <div class="col-lg-10 col-md-10">
                <input type="password" class="form-control" name="password" id="password" placeholder="密码" required autofocus/>
            </div>
            <div class="col-lg-10 col-md-10"></div>
            <div class="col-lg-10 mycheckbox checkbox">
                <input type="checkbox" id="rememberPassword" name="rememberPassword" class="col-lg-1">记住密码</input>
            </div>
            <div class="col-lg-10 col-md-10"></div>
            <div class="col-lg-10 col-md-10"></div>
            <div class="col-lg-10 col-md-10"></div>
            <div class="col-lg-10 col-md-10">
                <button type="button" onclick="checkLoginInfo()" class="btn btn-success col-lg-12 col-md-12 col-sm-12 col-xs-12">登录</button>
            </div>
        </div>
    </div>
</form>

</body>
</html>
<script>
    $(document).ready(function(){
        if ($.cookie("name")){    //取值如果存在则赋值
            var name = $.base64.decode($.cookie("name"));
            $("#username").val(name);
        }
        if ($.cookie("pwd")){    //取值如果存在则赋值
            var pwd = $.base64.decode($.cookie("pwd"));
            $("#password").val(pwd);
        }
    });
    function checkLoginInfo() {
        var userName = $('#username').val();
        var passWord = $('#password').val();

        var name = $.base64.encode(userName);
        var pwd = $.base64.encode(passWord);

        if(userName == ""){
            alert("用户名不能为空");
            $('#username').focus();
            return;
        }
        if(passWord == ""){
            alert("密码不能为空");
            $('#password').focus();
            return;
        }
        rememberPassword(name,pwd);
        $('#form').submit();
    }
    {/*本地记住密码 cookie*/}
    function rememberPassword(name,pwd){
        var isChecked = $("#rememberPassword").prop("checked");
        if(isChecked){
            if (confirm("记住密码？")) { //设置Cookie值
                $.cookie("name",name,{
                    expires:7,//设置保存期限
                    path:"/"//设置保存的路径
                });
                $.cookie("pwd",pwd,{
                    expires:7,//设置保存期限
                    path:"/"//设置保存的路径
                });
            }
            else {  //销毁对象
                $.cookie("name",null,{
                    path:"/"
                });
                $.cookie("pwd",null,{
                    path:"/"
                });
            }
        }
    }
</script>